<template>
  <el-container>
    <el-header height="60px">
      <el-col :span="12">
        <div class="grid-content bg-purple" align="left">
          <img src="../assets/logo.png" width="150px" height="50px">
        </div>
      </el-col>
      <el-col :span="12">
        <div class="grid-content bg-purple-light" align="right">
          <el-button plain>登录</el-button>
          <el-button plain>注册</el-button>
        </div>
      </el-col>
    </el-header>
    <el-main>

      <div class="block">

        <el-carousel indicator-position="none" height="350px">
          <el-carousel-item v-for="item in imgs">

            <img :src="item">

          </el-carousel-item>
        </el-carousel>
      </div>


      <div class="products">
        <div v-for="pro in pros" class="product">
          <img :src="pro.img"/>
          <br/>
          <h4>{{pro.name}}</h4>
          <h4>{{pro.price}}</h4>

          <el-button type="primary" round @click="gtproinfo(pro.pid)">立即购买</el-button>

        </div>

      </div>


    </el-main>
    <el-footer height="260px">Footer</el-footer>
  </el-container>

</template>


<script>


  export default {
    name: 'App',

    data () {
      return {
        imgs: [
          '../static/b1.jpg',
          '../static/b2.jpg'
        ],
        pros: null

      }
    },
    created () {
      this.getList()
    },
    methods: {

      getList: function () {
        const vm = this
        this.axios({
          method: 'GET',
          url: 'http://mock.amzpiper.com/mock/60b5e3338b2bd30020765379/example/products'
        }).then(function (resp) {
          console.log(resp.data)
          vm.pros = resp.data.props
        })
      },
      gtproinfo (pid) {
        this.$router.push('/productinfo/' + pid)
      }

    }
  }
</script>

<style scoped>

  .product {

    margin-top: 30px;
    display: inline-block;
    width: 30%;


  }

  .product img {


    width: 200px;
    height: 250px;


  }


  .el-header, .el-footer {
    margin-top: 10px;
    background-color: #ffffff;
    color: #333;
    text-align: center;
    line-height: 60px;
  }

  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 300px;
    margin: 0;
  }


  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    /*line-height: 560px;*/
    /*height: 800px;*/
    padding: 10px 0px 50px 0px;
  }

  body > .el-container {
    margin-bottom: 40px;
  }


</style>
